package database

import (
	"github.com/go-xorm/xorm"
	"log"
	_ "github.com/lib/pq"
	"git.oschina.net/fanbuchi/xgggh/users/proto/user/contact"
	"git.oschina.net/fanbuchi/xgggh/users/proto/user/profile"
)
var mMaster *xorm.Engine
func init() {
	postgres:="postgresql://feeds@localhost:26257/feeds?sslmode=disable"
	db, err := xorm.NewEngine("postgres",postgres)
	if err !=nil{
		log.Fatal(err)
	}
	err = db.Sync2(new(com_xgggh_srv_users_contact.Contact))
	err = db.Sync2(new(com_xgggh_srv_users_profile.Profile))
	if err !=nil{
		log.Fatal(err)
	}
	mMaster=db
	//defer db.Close()
}

func Master() *xorm.Engine{
	return mMaster
}
